import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TypeVO, TypeForm, TypeQuery } from '@/api/shopping/product/type/types';

/**
 * 查询商品分类列表
 * @param query
 * @returns {*}
 */

export const listType = (query?: TypeQuery): AxiosPromise<TypeVO[]> => {
  return request({
    url: '/shopping/product/type/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商品分类详细
 * @param id
 */
export const getType = (id: string | number): AxiosPromise<TypeVO> => {
  return request({
    url: '/shopping/product/type/' + id,
    method: 'get'
  });
};

/**
 * 新增商品分类
 * @param data
 */
export const addType = (data: TypeForm) => {
  return request({
    url: '/shopping/product/type',
    method: 'post',
    data: data
  });
};

/**
 * 修改商品分类
 * @param data
 */
export const updateType = (data: TypeForm) => {
  return request({
    url: '/shopping/product/type',
    method: 'put',
    data: data
  });
};

/**
 * 删除商品分类
 * @param id
 */
export const delType = (id: string | number | Array<string | number>) => {
  return request({
    url: '/shopping/product/type/' + id,
    method: 'delete'
  });
};
